package cn.edu.zafu.bigdata.x.sxy;

import java.util.List;

public class FindMax {
    public static <T extends Comparable<T>> T findMax(List<T> list){
        if(list.isEmpty()){
            System.out.println("The list is Empty!");
            return null;
        }
        T max = list.get(0);
        for(T item : list){
            if(item.compareTo(max) > 0){
                max = item;
            }
        }
        return max;
    }
//    public static void main(String[] args) {
//        List<Integer> intlst = List.of(1,1,4,5,1,4);
//        Integer Max;
//        Max = findMax(intlst);
//        System.out.println(Max);
//
//        List<String> strlst = List.of("Fangxingchen","Huzeqi","Huyan","Xingguangs");
//        String str;
//        str = findMax(strlst);
//        System.out.println(str);
//    }
}
